package multiThread;

public class Synchronized_demo {
	public int num = 10;

	public static void main(String[] args) {
//		new Thread(new myRunnable("test1")).start();
//		new Thread(new myRunnable("test2")).start();
		Synchronized_demo s = new Synchronized_demo();
		new Thread(new Runnable() {
			
			public void run() {
				s.delete();
			}
		}).start();
		new Thread(new Runnable() {
			
			@Override
			public void run() {
				s.delete();
			}
		}).start();
		
	}
	
	
	public void delete(){
		while(true){
			if(num == 0){
				System.out.println("hellp");
				break;
			}
//			synchronized (this) {
				System.out.println(num--);
//			}
			
		}
	}
	
//	static class myRunnable implements Runnable{
//		
//		private String name;
//		
//		public myRunnable(String name) {
//			this.name = name;
//		}
//
//		@Override
//		public void run() {
//			while(true){
//				if(num == 0){
//					throw new RuntimeException("numΪ0");
//				}
//				System.out.println(name+":"+ num--);
//			}
//		}
		
//	}
}
